from thrift.protocol.TBinaryProtocol import TBinaryProtocolFactory
from torthrift.transport import TIOStreamTransportFactory
from torthrift.server import TTornadoServer
from protocol.py.protocol.Rpc import Processor
from tornado.ioloop import IOLoop
from tornado import gen


class Handler(object):
    @gen.coroutine
    def call(self, body):
        print(body)
        raise gen.Return("rev"+body)

handler = Handler()
processor = Processor(handler)
tfactory = TIOStreamTransportFactory()
protocol =TBinaryProtocolFactory()

server = TTornadoServer(processor, tfactory, protocol)
server.bind(20000)
server.start(4)
IOLoop.instance().start()
